#[derive(Debug, PartialEq)]
pub enum TokenType {
    // 关键字
    Const,
    Int,
    Void,
    If,
    Else,
    While,
    Break,
    Continue,
    Return,
    // 运算符
    Plus,
    Minus,
    Mul,
    Div,
    Mod,
    Assign,
    Eq,
    Neq,
    Lt,
    Gt,
    Le,
    Ge,
    Not,
    And,
    Or,
    // 分隔符
    LParen,
    RParen,
    LBrace,
    RBrace,
    LBrackt,
    RBrackt,
    Comma,
    Semicolon,
    // 数值
    IntegerConst,
    // 标识符
    Ident,
    // 错误处理
    ErrorToken,
}

impl std::fmt::Display for TokenType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                TokenType::Const => "CONST",
                TokenType::Int => "INT",
                TokenType::Void => "VOID",
                TokenType::If => "IF",
                TokenType::Else => "ELSE",
                TokenType::While => "WHILE",
                TokenType::Break => "BREAK",
                TokenType::Continue => "CONTINUE",
                TokenType::Return => "RETURN",
                TokenType::Plus => "PLUS",
                TokenType::Minus => "MINUS",
                TokenType::Mul => "MUL",
                TokenType::Div => "DIV",
                TokenType::Mod => "MOD",
                TokenType::Assign => "ASSIGN",
                TokenType::Eq => "EQ",
                TokenType::Neq => "NEQ",
                TokenType::Lt => "LT",
                TokenType::Gt => "GT",
                TokenType::Le => "LE",
                TokenType::Ge => "GE",
                TokenType::Not => "NOT",
                TokenType::And => "AND",
                TokenType::Or => "OR",
                TokenType::LParen => "L_PAREN",
                TokenType::RParen => "R_PAREN",
                TokenType::LBrace => "L_BRACE",
                TokenType::RBrace => "R_BRACE",
                TokenType::LBrackt => "L_BRACKT",
                TokenType::RBrackt => "R_BRACKT",
                TokenType::Comma => "COMMA",
                TokenType::Semicolon => "SEMICOLON",
                TokenType::Ident => "IDENT",
                TokenType::IntegerConst => "INTEGER_CONST",
                TokenType::ErrorToken => "Error",
            }
        )
    }
}
